<?php
if( !defined('IN_INDEX') )
{
	printError("ACCESS DENIED", "This page is hidden.");
	exit;
}
$MENU_LIST[] = array('action' => 'home', 'keyword' => 'home', 'login' => 0);
//$MENU_LIST[] = array('action' => 'join', 'keyword' => 'join', 'login' => 1);
$MENU_LIST[] = array('action' => 'profile', 'keyword' => 'profile', 'login' => 2);
$MENU_LIST[] = array('action' => 'blogs', 'keyword' => 'blogs', 'login' => 2);
//$MENU_LIST[] = array('action' => 'groups', 'keyword' => 'groups', 'login' => 2);
//$MENU_LIST[] = array('action' => 'forum', 'keyword' => 'forum', 'login' => 4);
$MENU_LIST[] = array('action' => 'news', 'keyword' => 'news', 'login' => 2);
//$MENU_LIST[] = array('action' => 'search', 'keyword' => 'search', 'login' => 2);
$MENU_LIST[] = array('action' => 'gym', 'keyword' => 'gym_list_view', 'login' => 2,'sub'=>'list');

$include_submenu = true;

function print_menu($MENU_LIST)
{
	global $ACTION;
	
	foreach($MENU_LIST as $key => $val)
	{
		if($val['keyword'] == "home")
		{
			$output = "<li class=\"home";
		}
		else
		{
			$output = "<li class=\"page_item page-item-" . $key;
		}
		if($ACTION == $val['action'])
		{
			$output .= " current_page_item";
		}
		if($val['keyword'] == "home")
		{
			$output .= "\"><a class=\"home\"";
		}
		else
		{
			$output .= "\"><a ";
		}
		if(isset($val['sub']) AND $val['sub'] != "" ){
			$output .= "<a href=\"index.php?action=" . $val['action']  . "&amp;sub=" . $val['sub'] . "\">" . translate($val['keyword']) . "</a></li>\n";
		}else{
			$output .= "href=\"index.php?action=" . $val['action'] . "\">" . translate($val['keyword']) . "</a></li>\n";
		}
		if($val['login'] == 1)
		{
			if(!checkSession())
			{
				echo $output;
			}
		}
		else if($val['login'] == 2)
		{
			if(checkSession())
			{
				echo $output;
			}
		}
		else
		{
			echo $output;
		}
	}
}

function print_submenu($SUBMENU_LIST)
{
	global $ACTION, $SUB_ACTION;
	foreach($SUBMENU_LIST as $key => $val)
	{
		$output = "<li class=\"page_item page-item-" . $key;
		if($SUB_ACTION == $val['sub'])
		{
			$output .= " current_page_item";
		}

		$output .= "\"><a href=\"index.php?action=" . $ACTION . "&amp;sub=" . $val['sub'] . "\">" . translate($val['keyword']) . "</a></li>\n";
		if($val['login'] == 1)
		{
			if(!checkSession())
			{
				echo $output;
			}
		}
		else if($val['login'] == 2)
		{
			if(checkSession())
			{
				echo $output;
			}
		}
		else if($val['login'] == 5)
		{
			if(checkSession() && isset($USER) && ($USER->getRank() >= 5))
			{
				echo $output;
			}
		}
		else
		{
			echo $output;
		}
	}
}

function fetch_submenu($id)
{
	$array = array();
	switch($id)
	{
		case '':
		case 'home':
			$array[] = array('sub' => 'hof', 'keyword' => 'hof', 'login' => 2);
			$array[] = array('sub' => 'videos', 'keyword' => 'videos', 'login' => 2);
			$array[] = array('sub' => 'awards', 'keyword' => 'awards', 'login' => 2);
			$array[] = array('sub' => 'stats', 'keyword' => 'stats', 'login' => 2);
			break;
		case 'profile':
			//$array[] = array('sub' => 'home', 'keyword' => 'home', 'login' => 0);
			$array[] = array('sub' => 'newt', 'keyword' => 'newt', 'login' => 0);
			$array[] = array('sub' => 'friends', 'keyword' => 'friends', 'login' => 0);
			$array[] = array('sub' => 'info', 'keyword' => 'info', 'login' => 0);
			$array[] = array('sub' => 'stats', 'keyword' => 'stats', 'login' => 0);
			$array[] = array('sub' => 'pm', 'keyword' => 'pm', 'login' => 2);
			$array[] = array('sub' => 'tools', 'keyword' => 'tools', 'login' => 2);
			$array[] = array('sub' => 'edit', 'keyword' => 'edit', 'login' => 2);
			break;
		case 'news':
			//$array[] = array('sub' => 'archive', 'keyword' => 'news_archive', 'login' => 0);
			//$array[] = array('sub' => 'new', 'keyword' => 'write_news', 'login' => 5);
			break;
		case 'groups':
			//$array[] = array('sub' => 'new', 'keyword' => 'new', 'login' => 2);
			break;
		case 'blogs':
			//$array[] = array('sub' => 'stats', 'keyword' => 'stats', 'login' => 0);
			break;
		
		default:
			break;
	}
	return $array;
}
?>